/*	PureMVC AS3 / Flex Demo - Slacker 
	Copyright (c) 2008 Clifford Hall <clifford.hall@puremvc.org>
	Your reuse is governed by the Creative Commons Attribution 3.0 License */
package mvc.view
{
	import com.tools.traceTool.TraceTool;
	
	import components.MainDisplay;
	
	import flash.events.Event;
	
	import org.puremvc.as3.patterns.mediator.Mediator;

	public class ApplicationMediator extends Mediator
	{
		private var	mode:String;
		public static const NAME:String = 'ApplicationMediator';
		private	function Trace(...args):void{TraceTool.send('wTrace',String(Object(this).constructor),args);}

		public function ApplicationMediator( viewComponent:Object )
		{
			Trace('		START	constructor	'+this);
			super(NAME,viewComponent );
			Trace('		FINISH	constructor	'+this);
		}
		override public function onRegister():void
		{
			Trace('	onRegister	facade.registerMediator,	addEventListeners	');
			facade.registerMediator(new MainDisplayMediator(app.mainDisplay));
		    app.addEventListener(ArtGConfig.SHOW_HOME,		onShowHome);
		    app.addEventListener(ArtGConfig.SHOW_ABOUT,		onShowAbout);
		    app.addEventListener(ArtGConfig.SHOW_ART,		onShowArt);
		    app.addEventListener(ArtGConfig.SHOW_COLL, 		onShowColl);
		    app.addEventListener(ArtGConfig.SHOW_CONTACT,	onShowContact);
		    app.addEventListener(ArtGConfig.SHOW_TMP,		onShowTmp);
		}
		protected function onShowTmp(event:Event):void
		{
			sendNotification(mode);
			Trace('		FINISH	'+mode+'		'+MainDisplay(event.target).viewSelector);
		}
		protected function onShowHome(event:Event):void
		{
			mode=ArtGConfig.HOME_MODE;
			ArtGConfig.textAreaMsg=ArtGConfig.HOME_TEXT
			Trace('		START	'+mode+'		'+MainDisplay(event.target).viewSelector);
			sendNotification(ArtGConfig.TMP_MODE );
		}
		protected function onShowAbout(event:Event):void
		{
			mode=ArtGConfig.ABOUT_MODE;
			ArtGConfig.textAreaMsg=ArtGConfig.ABOUT_TEXT
			Trace('		START	'+mode+'		'+MainDisplay(event.target).viewSelector);
			sendNotification(ArtGConfig.TMP_MODE );
		}
		protected function onShowArt(event:Event):void
		{
			mode=ArtGConfig.ART_MODE;
			ArtGConfig.textAreaMsg=ArtGConfig.ART_TEXT
			Trace('		START	'+mode+'		'+MainDisplay(event.target).viewSelector);
			sendNotification(ArtGConfig.TMP_MODE );
		}
		protected function onShowContact(event:Event):void
		{
			mode=ArtGConfig.CONTACT_MODE;
			ArtGConfig.textAreaMsg=ArtGConfig.CONTACT_TEXT
			Trace('		START	'+mode+'		'+MainDisplay(event.target).viewSelector);
			sendNotification(ArtGConfig.TMP_MODE );
		}
		protected function onShowColl(event:Event):void
		{
			mode=ArtGConfig.COLL_MODE;
			Trace('		START	'+mode+'		'+MainDisplay(event.target).viewSelector);
			sendNotification(ArtGConfig.TMP_MODE );
		}
		protected function get app():ArtG	{return ArtG(viewComponent);}
	}
}